package com.example.tablelayoutdemo.slice;

import com.example.tablelayoutdemo.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.TableLayout;
import ohos.agp.components.Text;

public class MainAbilitySlice extends AbilitySlice {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);
        // 获取TableLayout中的第1个Text子组件
        Text text = (Text) findComponentById(ResourceTable.Id_text1);
        // 创建TableLayout布局配置对象
        TableLayout.LayoutConfig config = new TableLayout.LayoutConfig(300, 600);
        // 设置当前子元素所占的行数为2
        config.rowSpec = TableLayout.specification(TableLayout.DEFAULT, 2);
        // 设置子元素的布局配置
        text.setLayoutConfig(config);
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
